Ext.define("Admin.view.decMakConsultation.KnowledgeBase", {
    extend: "Admin.common.container.BaseContainer",
    xtype: "knowledgeBase",
    alias: "knowledgeBase",
    requires: [
        "Ext.panel.Panel",
        "Ext.grid.Panel",
        "Ext.button.Button",
        "Admin.common.form.SearchFormPanel",
        "Admin.store.decMakConsultation.KnowledgeExpert",
        "Admin.store.decMakConsultation.KnowledgeWarn",
        "Admin.store.decMakConsultation.HidstoryCase"
    ],
    viewModel: "knowledgeBase",
    controller: "knowledgeBase",
    height: 200,
    // cls: 'dashboard-main-chart shadow',
    items: [{
        xtype: "tabpanel",
        border: false,
        cls: "shadow",
        style: "border: 1px solid #ccc",
        items: [{
                title: "专家库",
                xtype: "baseGridPanel",
                reference: "expertGrid",
                border: false,
                columns: [{
                        header: "专家编号",
                        dataIndex: "code",
                        align: "center",
                        flex: 1,
                        hidden: true
                    },
                    { header: "姓名", dataIndex: "name", align: "center", flex: 1 },
                    { header: "所属单位", dataIndex: "dept", align: "center", flex: 1 },
                    { header: "专业领域", dataIndex: "major", align: "center", flex: 1 },
                    { header: "职称", dataIndex: "grade", align: "center", flex: 1 },
                    { header: "联系电话", dataIndex: "tel", align: "center", flex: 1 },
                    {
                        xtype: "actioncolumn",
                        text: "操作",
                        align: "center",
                        width: 100,
                        sortable: false,
                        menuDisabled: true,
                        items: [{
                                iconCls: "x-fa fa-edit",
                                tooltip: "编辑",
                                handler: "expertUpdata"
                            },
                            {
                                iconCls: "x-fa fa-times-circle",
                                tooltip: "删除",
                                handler: "expertDel"
                            }
                        ]
                    }
                ],
                bind: {
                    store: "{knowledgeExpert}"
                },
                tbar: [{
                        xtype: "searchFormPanel",
                        columns: 2,
                        items: [
                            // {
                            // 	xtype: "textfield",
                            // 	fieldLabel: "姓名",
                            // 	reference: "expertName"
                            // },
                            {
                                xtype: "combobox",
                                fieldLabel: "姓名",
                                reference: "expertName",
                                displayField: 'name',
                                queryMode: 'local',
                                valueField: 'name',
                                triggerAction: 'all',
                                anyMatch: true,
                                listeners: {
                                    added: function(combo) {
                                        var _that = this;
                                        var store = Ext.create("Ext.data.Store", {
                                            autoLoad: true,
                                            proxy: {
                                                type: "ajax",
                                                extraParams: { river: config.RIVER },
                                                url: config.URL + "szy/dispatch/meeting/ddsSExp/list",
                                                reader: {
                                                    type: "json",
                                                    rootProperty: "list",
                                                    fields: ["name"]
                                                }
                                            },
                                            listeners: {
                                                load: function() {
                                                    var k, repeat = [],
                                                        state = {};
                                                    this.each(function(r) {
                                                        k = r.get('name');
                                                        if (state[k]) repeat.push(r);
                                                        else state[k] = true;
                                                    });
                                                    this.remove(repeat);
                                                }
                                            }
                                        });
                                        combo.setStore(store);
                                        // store.on('endupdate', function () {
                                        // 	if (!combo.getValue()) {
                                        // 		combo.setValue(store.getAt(0).get('conId'))
                                        // 	}
                                        // })
                                    }
                                }
                            },
                            // {
                            // 	xtype: "textfield",
                            // 	fieldLabel: "职称",
                            // 	reference: "expertGrade"
                            // },								
                            {
                                xtype: "combobox",
                                fieldLabel: "职称",
                                reference: "expertGrade",
                                displayField: 'grade',
                                queryMode: 'local',
                                valueField: 'grade',
                                triggerAction: 'all',
                                anyMatch: true,
                                listeners: {
                                    added: function(combo) {
                                        var _that = this;
                                        var store = Ext.create("Ext.data.Store", {
                                            autoLoad: true,
                                            proxy: {
                                                type: "ajax",
                                                extraParams: { river: config.RIVER },
                                                url: config.URL + "szy/dispatch/meeting/ddsSExp/list",
                                                reader: {
                                                    type: "json",
                                                    rootProperty: "list",
                                                    fields: ["grade"]
                                                }
                                            },
                                            listeners: {
                                                load: function() {
                                                    var k, repeat = [],
                                                        state = {};
                                                    this.each(function(r) {
                                                        k = r.get('grade');
                                                        if (state[k]) repeat.push(r);
                                                        else state[k] = true;
                                                    });
                                                    this.remove(repeat);
                                                }
                                            }
                                        });
                                        combo.setStore(store);
                                        // store.on('endupdate', function () {
                                        // 	if (!combo.getValue()) {
                                        // 		combo.setValue(store.getAt(0).get('conId'))
                                        // 	}
                                        // })
                                    }
                                }
                            },
                        ]
                    },
                    "->",
                    {
                        xtype: "button",
                        iconCls: "x-fa fa-search",
                        text: "查询",
                        handler: "expertSearch"
                    },
                    {
                        xtype: "button",
                        iconCls: "x-fa fa-save",
                        text: "新增",
                        handler: "expertAdd"
                    }
                ],
                bbar: {
                    xtype: "pagingtoolbar",
                    autoLoad: true,
                    displayInfo: true,
                    displayMsg: "显示从第{0}条数据到第{1}条数据，共{2}条数据",
                    emptyMsg: "没有记录"
                }
            },
            {
                title: "应急预案",
                xtype: "baseGridPanel",
                reference: "warnPlanGrid",
                columns: [
                    { header: "标题", dataIndex: "title", align: "center", flex: 1 },
                    { header: "创建人", dataIndex: "creator", align: "center", flex: 1 },
                    // { header: "创建人", dataIndex: "creator", align: "center", flex: 1 },
                    {
                        header: "类别",
                        dataIndex: "knoType",
                        align: "center",
                        flex: 1,
                        renderer: function(value) {
                            return getValue('knotype', value);
                        }
                    },
                    { header: "创建日期", dataIndex: "dt", align: "center", flex: 1 },
                    { header: "关键字", dataIndex: "keys", align: "center", flex: 1 },
                    { header: "备注", dataIndex: "nt", align: "center", flex: 1 },
                    {
                        xtype: "actioncolumn",
                        text: "操作",
                        align: "center",
                        width: 100,
                        sortable: false,
                        menuDisabled: true,
                        items: [{
                                iconCls: "x-fa fa-edit",
                                tooltip: "编辑",
                                handler: "warnPlanUpdata"
                            },
                            {
                                iconCls: "x-fa fa-times-circle",
                                tooltip: "删除",
                                handler: "warnPlanDel"
                            }
                        ]
                    }
                ],
                bind: {
                    store: "{knowledgeWarn}"
                },
                tbar: [{
                        xtype: "searchFormPanel",
                        columns: 2,
                        items: [
                            // {
                            // 	xtype: "textfield",
                            // 	fieldLabel: "标题",
                            // 	reference: "warnPlanTitle"
                            // },
                            {
                                xtype: "combobox",
                                fieldLabel: "标题",
                                reference: "warnPlanTitle",
                                displayField: 'title',
                                queryMode: 'local',
                                valueField: 'title',
                                triggerAction: 'all',
                                anyMatch: true,
                                listeners: {
                                    added: function(combo) {
                                        var _that = this;
                                        var store = Ext.create("Ext.data.Store", {
                                            autoLoad: true,
                                            proxy: {
                                                type: "ajax",
                                                extraParams: { river: config.RIVER },
                                                url: config.URL + "szy/dispatch/meeting/ddsSKno/list",
                                                reader: {
                                                    type: "json",
                                                    rootProperty: "list",
                                                    fields: ["title"]
                                                }
                                            },
                                            listeners: {
                                                load: function() {
                                                    var k, repeat = [],
                                                        state = {};
                                                    this.each(function(r) {
                                                        k = r.get('title');
                                                        if (state[k]) repeat.push(r);
                                                        else state[k] = true;
                                                    });
                                                    this.remove(repeat);
                                                }
                                            }
                                        });
                                        combo.setStore(store);
                                        // store.on('endupdate', function () {
                                        // 	if (!combo.getValue()) {
                                        // 		combo.setValue(store.getAt(0).get('conId'))
                                        // 	}
                                        // })
                                    }
                                }
                            },
                            {
                                xtype: "dicComboBox",
                                dicType: "knotype",
                                fieldLabel: "类别",
                                reference: "warnPlanType"
                            }
                        ]
                    },
                    "->",
                    {
                        xtype: "button",
                        iconCls: "x-fa fa-search",
                        text: "查询",
                        handler: "warnPlanSearch"
                    },
                    {
                        xtype: "button",
                        iconCls: "x-fa fa-save",
                        text: "新增",
                        handler: "warnPlanAdd"
                    }
                ],
                bbar: {
                    xtype: "pagingtoolbar",
                    autoLoad: true,
                    displayInfo: true,
                    displayMsg: "显示从第{0}条数据到第{1}条数据，共{2}条数据",
                    emptyMsg: "没有记录"
                }
            },
            {
                title: "历史案例",
                xtype: "baseGridPanel",
                reference: "historyCaseGrid",
                bind: {
                    store: "{hidstoryCase}"
                },
                columns: [
                    { header: "发生时间", dataIndex: "hapDt", align: "center", flex: 1 },
                    { header: "id", dataIndex: "id", align: "center", flex: 1, hidden: true },
                    { header: "发生地点", dataIndex: "loc", align: "center", flex: 1 },
                    { header: "事件信息", dataIndex: "sinfo", align: "center", flex: 1 },
                    {
                        header: "处置方法及结果",
                        dataIndex: "sresult",
                        align: "center",
                        flex: 1
                    },
                    {
                        header: "案例ID",
                        dataIndex: "id",
                        align: "center",
                        flex: 1,
                        hidden: true
                    },
                    {
                        xtype: "actioncolumn",
                        text: "操作",
                        align: "center",
                        width: 100,
                        sortable: false,
                        menuDisabled: true,
                        items: [{
                                iconCls: "x-fa fa-edit",
                                tooltip: "编辑",
                                handler: "historyCaseUpdata"
                            },
                            {
                                iconCls: "x-fa fa-times-circle",
                                tooltip: "删除",
                                handler: "historyCaseDel"
                            }
                        ]
                    }
                ],
                tbar: [{
                        xtype: "form",
                        layout: "column",
                        defaults: {
                            margin: "0 10 0 0",
                            labelWidth: 65
                        },
                        items: [
                            // {
                            // 	xtype: "textfield",
                            // 	fieldLabel: "发生地点",
                            // 	reference: "historyCaseLoc"
                            // },
                            {
                                xtype: "combobox",
                                fieldLabel: "发生地点",
                                reference: "historyCaseLoc",
                                displayField: 'loc',
                                queryMode: 'local',
                                valueField: 'loc',
                                triggerAction: 'all',
                                anyMatch: true,
                                listeners: {
                                    added: function(combo) {
                                        var _that = this;
                                        var store = Ext.create("Ext.data.Store", {
                                            autoLoad: true,
                                            proxy: {
                                                type: "ajax",
                                                extraParams: { river: config.RIVER },
                                                url: config.URL + "szy/dispatch/meeting/ddsSCase/list",
                                                reader: {
                                                    type: "json",
                                                    rootProperty: "list",
                                                    fields: ["loc"]
                                                }
                                            },
                                            listeners: {
                                                load: function() {
                                                    var k, repeat = [],
                                                        state = {};
                                                    this.each(function(r) {
                                                        k = r.get('loc');
                                                        if (state[k]) repeat.push(r);
                                                        else state[k] = true;
                                                    });
                                                    this.remove(repeat);
                                                }
                                            }
                                        });
                                        combo.setStore(store);
                                        // store.on('endupdate', function () {
                                        // 	if (!combo.getValue()) {
                                        // 		combo.setValue(store.getAt(0).get('conId'))
                                        // 	}
                                        // })
                                    }
                                }
                            }
                        ]
                    },
                    "->",
                    {
                        xtype: "button",
                        iconCls: "x-fa fa-search",
                        text: "查询",
                        handler: "historyCaseSearch"
                    },
                    {
                        xtype: "button",
                        iconCls: "x-fa fa-save",
                        text: "新增",
                        handler: "historyCaseAdd"
                    }
                ],
                bbar: {
                    xtype: "pagingtoolbar",
                    autoLoad: true,
                    displayInfo: true,
                    displayMsg: "显示从第{0}条数据到第{1}条数据，共{2}条数据",
                    emptyMsg: "没有记录"
                }
            }
        ]
    }]
});

//专家库新增/修改的form表单
Ext.define("Admin.view.emergencyDispatch.ExpertForm", {
    // extend: 'Ext.form.Panel',
    extend: "Admin.common.form.BaseFormPanel",
    xtype: "expertForm",
    alias: "expertForm",
    bodyPadding: 10,
    layout: "anchor",
    defaults: {
        anchor: "100%",
        labelWidth: 60,
        labelAlign: "right"
    },
    items: [{
            xtype: "panel",
            layout: "hbox",
            defaultType: "textfield",
            margin: "0 0 10 0",
            defaults: {
                labelWidth: 60,
                labelAlign: "right"
            },
            items: [{
                    fieldLabel: "姓名",
                    name: "name",
                    allowBlank: false,
                    flex: 1,
                    margin: "0 10 0 0"
                },
                {
                    fieldLabel: "籍贯",
                    allowBlank: true,
                    name: "naplace",
                    flex: 1
                }
            ]
        },
        {
            xtype: "panel",
            layout: "hbox",
            defaultType: "textfield",
            margin: "0 0 10 0",
            defaults: {
                labelWidth: 60,
                labelAlign: "right"
            },
            items: [{
                    fieldLabel: "年龄",
                    allowBlank: true,
                    name: "age",
                    xtype: 'numberfield',
                    flex: 1,
                    margin: "0 10 0 0"
                },
                {
                    fieldLabel: "毕业院校",
                    allowBlank: true,
                    name: "university",
                    flex: 1
                }
            ]
        },
        {
            xtype: "panel",
            layout: "hbox",
            defaultType: "textfield",
            margin: "0 0 10 0",
            defaults: {
                labelWidth: 60,
                labelAlign: "right"
            },
            items: [{
                    fieldLabel: "所属单位",
                    name: "dept",
                    flex: 1,
                    margin: "0 10 0 0"
                },
                {
                    fieldLabel: "专业领域",
                    name: "major",
                    flex: 1
                }
            ]
        },
        {
            xtype: "panel",
            layout: "hbox",
            defaultType: "textfield",
            margin: "0 0 10 0",
            defaults: {
                labelWidth: 60,
                labelAlign: "right"
            },
            items: [{
                    fieldLabel: "职务",
                    name: "post",
                    vertical: true,
                    flex: 1,
                    margin: "0 10 0 0"
                },
                {
                    fieldLabel: "职称",
                    vertical: true,
                    name: "grade",
                    flex: 1
                }
            ]
        },
        {
            xtype: "radiogroup",
            fieldLabel: "性别",
            columns: 2,
            vertical: true,
            items: [
                { boxLabel: "男", name: "sex", inputValue: "1", checked: true },
                { boxLabel: "女", name: "sex", inputValue: "2" }
            ]
        },
        {
            xtype: "panel",
            layout: "hbox",
            defaultType: "textfield",
            margin: "0 0 10 0",
            defaults: {
                labelWidth: 60,
                labelAlign: "right"
            },
            items: [{
                    fieldLabel: "联系电话",
                    name: "tel",
                    flex: 1,
                    margin: "0 10 0 0"
                },
                {
                    fieldLabel: "邮箱",
                    vtype: "email",
                    name: "mail",
                    flex: 1
                }
            ]
        },
        {
            xtype: "fieldcontainer",
            fieldLabel: "熟悉专业",
            layout: "hbox",
            items: [{
                    xtype: "textfield",
                    flex: 1,
                    emptyText: "第一熟悉专业",
                    name: "firmaj"
                },
                {
                    xtype: "splitter"
                },
                {
                    xtype: "textfield",
                    flex: 1,
                    emptyText: "第二熟悉专业",
                    name: "secmaj"
                },
                {
                    xtype: "splitter"
                },
                {
                    xtype: "textfield",
                    flex: 1,
                    emptyText: "第三熟悉专业",
                    name: "thimaj"
                }
            ]
        },
        {
            xtype: "textareafield",
            grow: true,
            name: "profile",
            fieldLabel: "个人简介",
            anchor: "100%"
        },
        {
            xtype: "textareafield",
            grow: true,
            name: "comments",
            fieldLabel: "推荐意见",
            anchor: "100%"
        },
        {
            xtype: "textfield",
            name: "code",
            hidden: true
        }
    ]
});

//应急预案/历史预案  新增/修改的form表单
Ext.define("Admin.view.emergencyDispatch.WarnPlanForm", {
    // extend: 'Ext.form.Panel',
    extend: "Admin.common.form.BaseFormPanel",
    xtype: "warnPlanForm",
    alias: "warnPlanForm",
    bodyPadding: 10,
    layout: "anchor",
    defaults: {
        anchor: "100%",
        labelWidth: 60,
        labelAlign: "right"
    },
    items: [{
            xtype: "textfield",
            grow: true,
            name: "title",
            fieldLabel: "标题",
            allowBlank: false,
            anchor: "100%"
        },
        {
            xtype: "panel",
            layout: "hbox",
            defaultType: "textfield",
            margin: "0 0 10 0",
            defaults: {
                labelWidth: 60,
                labelAlign: "right"
            },
            items: [{
                    fieldLabel: "创建人",
                    allowBlank: false,
                    name: "creator",
                    flex: 1,
                },
                {
                    xtype: "datetimefield",
                    editable: false,
                    fieldLabel: "创建日期",
                    allowBlank: false,
                    name: "dt",
                    flex: 1
                }
            ]
        },
        {
            xtype: "panel",
            layout: "hbox",
            defaultType: "textfield",
            margin: "0 0 10 0",
            defaults: {
                labelWidth: 60,
                labelAlign: "right"
            },
            items: [{
                    xtype: "dicComboBox",
                    allowBlank: false,
                    flex: 1,
                    name: "knoType",
                    dicType: "knotype",
                    fieldLabel: "类别",
                },
                {
                    fieldLabel: "关键字",
                    name: "keys",
                    flex: 1
                }
            ]
        },
        {
            xtype: "textareafield",
            grow: true,
            name: "nt",
            fieldLabel: "备注",
            anchor: "100%"
        },
        {
            xtype: "textareafield",
            grow: true,
            fieldLabel: "内容",
            name: "content",
            allowBlank: false,
            anchor: "100%"
        },
        {
            xtype: "textfield",
            name: "knoId",
            hidden: true
        }
    ]
});

//历史案例  新增/修改的form表单
Ext.define("Admin.view.emergencyDispatch.HistoryCaseForm", {
    // extend: 'Ext.form.Panel',
    extend: "Admin.common.form.BaseFormPanel",
    xtype: "historyCaseForm",
    alias: "historyCaseForm",
    bodyPadding: 10,
    layout: "anchor",
    defaults: {
        anchor: "100%",
        labelWidth: 60,
        labelAlign: "right"
    },
    items: [{
            xtype: "datefield",
            grow: true,
            name: "hapDt",
            fieldLabel: "发生时间",
            editable: false,
            allowBlank: false,
            anchor: "100%",
            format: 'Y-m-d',
        },
        {
            xtype: "textfield",
            grow: true,
            name: "loc",
            fieldLabel: "发生地点",
            allowBlank: false,
            anchor: "100%"
        },
        {
            xtype: "textfield",
            name: "id",
            fieldLabel: "发生地点",
            anchor: "100%",
            hidden: true,
        },
        {
            xtype: "textfield",
            grow: true,
            name: "sinfo",
            fieldLabel: "事件信息",
            allowBlank: false,
            anchor: "100%"
        },
        {
            xtype: "textfield",
            grow: true,
            name: "sresult",
            fieldLabel: "处置方法及结果",
            allowBlank: false,
            anchor: "100%"
        }
    ]
});